package com.tyl.xtk.beans.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * create by tyl at 2025/8/27
 */
@Setter
@Getter
public class PageResult<T> extends Result<List<T>> {
    private long total;
    private long pageNum;
    private long pageSize;

    private PageResult(int code, String message, List<T> data, long pageNum, long pageSize, long total) {
        super(code, message, data);
        this.total = total;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public static <H> PageResult<H> success(IPage<H> page) {
        return new PageResult<>(200, "success", page.getRecords(), page.getCurrent(), page.getSize(), page.getTotal());
    }
}
